/* vpw.t   VENDOR ITEM MASTER WRITE TRIGGER                           */
/*Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                 */
/*All rights reserved worldwide.  This is an unpublished work.        */
/*V8:ConvertMode=NoConvert*/
/*********************************************************************/
/*  Program :vpw.t                                                   */
/*  Author  :Gurgen Mkhitaryan  (gym)                                */
/*  Date    :10/17/96                                                */
/*  !Description : vp_mstr WRITE trigger program                     */
/*          : In order to enhance this trigger to support additional */
/*          : interfaces, add a DO-END block similar to the one      */
/*          : used for the Warehousing Interface to (1) check for the*/
/*          : need to continue processing; (2) move the relevant     */
/*          : fields to an appropriate work area; and (3) call       */
/*          : one or more subprograms to continue processing.        */
/*          : This .t program should remain short, relying on        */
/*          : subprograms to perform most of the work.               */
/*********************************************************************/
/*                             MODIFY LOG                            */
/*********************************************************************/
/*Revision 8.6          Last Modified:  10/17/96 BY: gym      *K015* */
/*Revision 8.6          Last Modified:  01/07/97 BY: jpm      *J1DM* */
/*Revision 9.1          Last Modified:  08/12/00 BY: *N0KC* myb       */
/*                                                                   */
/*                                                                   */
/*********************************************************************/

trigger procedure for write of vp_mstr old buffer old_vp_mstr.

         /* THIS TRIGGER PROCEDURE SHOULD MAKE A QUICK CHECK FOR ANY */
         /* ROUTINES THAT NEED TO BE EXECUTED AS A RESULT OF THIS    */
         /* TRIGGER FIRING. IF NO ROUTINES NEED TO BE CALLED THEN    */
         /* RETURN WITHOUT DOING ANYTHING.                           */


         /* GLOBAL VARIABLES */
         {mfdeclre.i}

         /* LOCAL VARIABLES */
         define variable warehousing_active as logical no-undo.

         /* SHARED WORK TABLES */
         define new shared variable w-site-loc-id like whl_mstr.whl_src_dest_id.
         define new shared work-table wf_old_vp_mstr like vp_mstr.


         WI: /* WAREHOUSING INTERFACE PROCESSING */
         do:

             warehousing_active = true.

             /* CHECK IF WAREHOUSE INTERFACE IS ACTIVE */
             if not can-find(first whl_mstr no-lock
                 where whl_mstr.whl_act and whl_mstr.whl_sup_item_nbr_exp)
             then warehousing_active = false.

            /* If no pertinent fields have been changed, then do not process */
             if   (old_vp_mstr.vp_part      = vp_mstr.vp_part
               and old_vp_mstr.vp_vend      = vp_mstr.vp_vend
               and old_vp_mstr.vp_vend_part = vp_mstr.vp_vend_part
               and old_vp_mstr.vp_um        = vp_mstr.vp_um
               and old_vp_mstr.vp_user1     = vp_mstr.vp_user1
               and old_vp_mstr.vp_user2     = vp_mstr.vp_user2
               and old_vp_mstr.vp_pkg_code  = vp_mstr.vp_pkg_code
               and old_vp_mstr.vp_ins_rqd   = vp_mstr.vp_ins_rqd
               and old_vp_mstr.vp_rcpt_stat = vp_mstr.vp_rcpt_stat)
             then warehousing_active = false.



             if warehousing_active then do:

                 /* COPY THE OLD RECORD BUFFER INTO THE WORKFILE FOR  */
                 /* LATER COMPARISONS TO THE NEW RECORD BUFFER        */

                 create wf_old_vp_mstr.
                 assign
                     wf_old_vp_mstr.vp_part      = old_vp_mstr.vp_part
                     wf_old_vp_mstr.vp_vend      = old_vp_mstr.vp_vend
                     wf_old_vp_mstr.vp_vend_part = old_vp_mstr.vp_vend_part
                     wf_old_vp_mstr.vp_um        = old_vp_mstr.vp_um
                     wf_old_vp_mstr.vp_user1     = old_vp_mstr.vp_user1
                     wf_old_vp_mstr.vp_user2     = old_vp_mstr.vp_user2
                     wf_old_vp_mstr.vp_pkg_code  = old_vp_mstr.vp_pkg_code
                     wf_old_vp_mstr.vp_ins_rqd   = old_vp_mstr.vp_ins_rqd
                     wf_old_vp_mstr.vp_rcpt_stat = old_vp_mstr.vp_rcpt_stat
                     .

                 /* WAREHOUSE INTERFACE VP_MSTR WRITE ROUTINE */
/*J1DM*/ /*      {gprun.i ""wivpw.p"" "(recid(vp_mstr))"} */
/*J1DM*/         {gprunmo.i &module="WI"
                            &program="wivpw.p"
                            &param="(recid(vp_mstr))"}


             end. /* IF WAREHOUSE INTERFACE ACTIVE */

         end. /* WI */

HK:
do:
    if can-find(first dt_mstr where dt_table = "vp_mstr" and dt_type = "SYNC") then
        run CreateSyncFlag(input "MOD", input recid(vp_mstr), input "vp_mstr").
end.

{hkdttrans.i}
